package server;

import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Logger {
	public static final int LOG_ERROR = 10;
	public static final int LOG_STATUS = 5;
	public static final int LOG_INFO = 0;
	
	private static PrintStream logStream;
	private static int loggingLevel;
	private static SimpleDateFormat dateFormat;

	static  {
		Logger.logStream = System.out;
		Logger.dateFormat = new SimpleDateFormat("hh:mm:ss");	
	}		
	
	public static void setOutputStream(PrintStream stream) {
		Logger.logStream = stream;
	}
	
	public static void setLogLevel(int level) {
		Logger.loggingLevel = level;
	}
	
	public static void setDateFormat(SimpleDateFormat format) {
		Logger.dateFormat = format;
	}

	public static void logEvent(String message, int level){
		if(level >= Logger.loggingLevel)		
			logStream.println(dateFormat.format(new Date()) + " " + message);
	}
}
